package cool.taomu.box.kademlia.test

import cool.taomu.toolkit.kademlia.entity.KademliaNode
import cool.taomu.toolkit.kademlia.service.RoutingTable
import cool.taomu.toolkit.kademlia.utils.KademliaUtils
import org.junit.Test

class RoutingTableTest {

	@Test
	def void a() {
		var node = new KademliaNode("1100", "192.168.1.2", 80, 1,0)
		var tr = new RoutingTable(node, 2);
		println(tr.buckets);
		var node2 = new KademliaNode("1110", "192.168.1.3", 80, 1,0)
		tr.addNode(node2,[]);
		println(tr.buckets);
		var node3 = new KademliaNode("1101", "192.168.1.3", 80, 1,0)
		tr.addNode(node3,[]);
		println(tr.buckets);
		var node4 = new KademliaNode("1111", "192.168.1.3", 80, 1,0)
		tr.addNode(node4,[]);
		println(tr.buckets);
		var nodes = tr.findClosestNodes("1111", 8)
		println(nodes);
	}

	@Test
	def void b() {
		var node = new KademliaNode("1100", "192.168.1.2", 80, 1,0)
		var node2 = new KademliaNode("1100", "192.168.1.2", 80, 1,0)
		var tr = new RoutingTable(node, 2);
		println(tr.localNode.equals(node2));
	}
}
